<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue 条件</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app-1">
        <div>v-if</div>
        <div v-if="isShow">{{ message }}</div>
        <button @click="handleClick">toggle</button>
    </div>

    <div id="app-2">
        <h3>v-show</h3>
        <div v-show="isShow">{{ message }}</div>
        <button @click="handleClick">toggle</button>
    </div>
  
  
    <div id="app-3">
        <h3>v-for array : index value</h3>
        <ul>
            <li v-for="(value, index)  in message" :key="index"> {{ index }}: {{ value }}</li>
        </ul>
    </div>

    <div id="app-4">
        <h3>v-for object : index key value</h3>
        <ul>
            <li v-for="(value, key, index)  in message" :key="index"> {{ index }}. {{ key }}: {{ value }}</li>
        </ul>
    </div>
  
</body>
<script>
   
    var app = new Vue({
        el: '#app-1',
        data: {
            message: 'Hello Vue!',
            isShow: true,
        },
        methods: {
            handleClick:function(){
                this.isShow = !this.isShow;
            }
        }
    })
    var app2 = new Vue({
        el: '#app-2',
        data: {
            message: 'Hello Vue!',
            isShow: true,
        },
        methods: {
            handleClick:function(){
                this.isShow = !this.isShow;
            }
        }
    })
   
    var app3 = new Vue({
        el: '#app-3',
        data: {
            message: ['hello ','vuejs ','!'],
        }
    })

    var app4 = new Vue({
        el: '#app-4',
        data: {
            message:{
                firstName: 'John',
                lastName: 'Doe',
                age: 30
            }
        }
    })


   
</script>

</html>